import React, { useState, useEffect } from "react";
import { View, Swiper, SwiperItem, Image } from "@tarojs/components";
import CsCalendar from "./cs-calendar";
import { AtCalendar } from "taro-ui";
export default (props) => {
  const [showBigCa, setShowBigCa] = useState(false);
  const onSelectDate = (e) => {
    props.onSelectDate(new Date(e.value.start));
  };
  const onCsSelectDate = (e) => {
    props.onSelectDate(new Date(e));
  };
  const downarrClick = (type) => {
    setShowBigCa(type);
  };

  return (
    <View className="calendar">
      {showBigCa ? (
        <AtCalendar
          currentDate={props.currentDate}
          onSelectDate={onSelectDate}
        />
      ) : (
          <CsCalendar
            currentDate={props.currentDate}
            onCsSelectDate={onCsSelectDate}
          />
        )}
      <View className="downarr">
        {showBigCa ? (
          <Image
            src={require("../../assets/schedule/uparr.png")}
            onClick={() => {
              downarrClick(false);
            }}
          />
        ) : (
            <Image
              src={require("../../assets/schedule/downarr.png")}
              onClick={() => {
                downarrClick(true);
              }}
            />
          )}
      </View>
    </View>
  );
};
